# coding:utf8
import httplib,time,sys,smtplib
reload(sys)
sys.setdefaultencoding('utf8')
from email.mime.text import MIMEText
mailto_list=["2683498900@qq.com"]
mail_host="mail.qq.com"
mail_user="2683498900"
mail_pass="1977147031asd"
mail_postfix="qq.com"
sec=60
conn = httplib.HTTPConnection("网站地址")
conn.request("GET", "搜索后的网站地址|/caigou/kw-%E6%B1%A1%E6%B0%B4%E5%A4%84%E7%90%86%E6%8B%9B%E6%A0%87.html")
r1 = conn.getresponse()
a = r1.read()
def send_mail(to_list,sub,content):
    me="网站信息已更新"+"<"+mail_user+"@"+mail_postfix+">"
    msg = MIMEText(content,_subtype='html',_charset='utf8')
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(to_list)
    try:
        s = smtplib.SMTP()
        s.connect(mail_host)
        s.login(mail_user,mail_pass)
        s.sendmail(me, to_list, msg.as_string())
        s.close()
        return True
    except Exception, e:
        print str(e)
        return False
print"The program is starting"
while True:
    time.sleep(sec)
    b = r1.read()
    if a == b:
        print'good running ,Now it is ' + time.strftime('%Y年%m月%d日,%H:%M:%S')+ '\n请稍后.....'
    else:
        print"网站更新"
if __name__ == '__main__':
    if send_mail(mailto_list, "网站信息已更新", "对应网站域名"):
        print"发送成功"
    else:
        print"发送失败"
    a = r1.read()
# 此项未解决